import pymysql
import  uuid

# 连接mysql数据库

connect = pymysql.Connect(
    host='localhost',
    port=3306,
    user='root',
    passwd='123456',
    db='test',
    charset='utf8'
)

cursor = connect.cursor()

sql="INSERT INTO user (username, age,id) VALUES ('%s', '%s','%s');"
data=('nihao','12',uuid.uuid4())


cursor.execute(sql % data)
cursor.close()

connect.commit()
connect.close()
print('添加一条数据',cursor.rowcount)
